<template>
  <div>
    <!-- 面包屑 -->
    <MBX l1="订单管理" l2="订单列表"></MBX>
    <!-- 卡片 -->
    <el-card class="xia">
      <el-input
        placeholder="请输入内容"
        class="input-with-select"
        v-model="obj.query"
        @input="toSreach"
        clearable
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="toSreach"
        ></el-button>
      </el-input>
      <!-- 表格 -->
      <el-table border class="xia" :data="OrdersFrom">
        <el-table-column label="#" type="index"></el-table-column>
        <el-table-column
          label="订单编号"
          prop="order_number"
          width="300"
        ></el-table-column>
        <el-table-column label="订单价格" prop="order_price"></el-table-column>
        <el-table-column label="是否付款">
          <template slot-scope="scope">
            <div>
              <el-tag type="danger" v-show="scope.row.pay_status == 0"
                >未付款</el-tag
              >
              <el-tag type="primary" v-show="scope.row.pay_status == 1"
                >已付款</el-tag
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send">
          <template slot-scope="scope">
            <div>
              <el-tag type="success" v-show="scope.row.is_send == '是'"
                >已发货</el-tag
              >
              <el-tag type="danger" v-show="scope.row.is_send == '否'"
                >未发货</el-tag
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column label="下单时间">
          <template slot-scope="scope">
            <div>
              <!-- 过滤时间 -->
              {{ scope.row.create_time | time }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <div>
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-edit"
                @click="showAddress"
              ></el-button>
              <el-button
                size="mini"
                type="success"
                icon="el-icon-map-location"
                @click="WL"
              ></el-button>
              <el-button
                size="mini"
                type="success"
                icon="el-icon-map-location"
                @click="DD(scope.row)"
              ></el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- // 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 40, 100]"
        :page-size="obj.pagesize"
        :current-page="obj.pagenum"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        class="xia"
      >
      </el-pagination>
    </el-card>
    <!-- 地址弹框 -->
    <el-dialog title="修改地址" :visible.sync="dialogFormVisible">
      <el-form :model="from">
        <el-form-item label="省市区/县" label-width="100px">
          <!-- 级联选择器 -->
          <el-cascader
            v-model="checkArr"
            :options="Options"
            :props="props"
            @change="handleChange"
            class="jl"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" label-width="100px">
          <el-input class="in1" v-model="from.Input"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <!-- 地址弹框 -->
    <el-dialog title="查看物流进度" :visible.sync="dialogFormVise">
      <!--  物流内容 -->
      <el-timeline :reverse="false">
        <el-timeline-item
          v-for="(item, index) in activities"
          :key="index"
          :timestamp="item.time"
          :color="item.color"
          :icon="item.icon"
        >
          {{ item.context }}
        </el-timeline-item>
      </el-timeline>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVise = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVise = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <!-- 修改订单状态 -->
    <el-dialog title="订单状态" :visible.sync="dialogFmVisible">
      <el-form :model="from">
        <el-form-item label="修改订单状态" label-width="100px">
          <el-input class="in1" v-model="from.Input"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFmVisible = false">取 消</el-button>
        <el-button type="primary" @click="getDDzt">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// import _ from 'lodash'
import Addres from '@/Addres/addres'
import WL from '@/WL/wl'
console.log(Addres)
export default {
  name: '',
  components: {},
  data() {
    return {
      from: {
        Input: ''
      },
      checkArr: [],
      Options: [],
      activities: [],
      props: {
        expandTrigger: 'hover',
        children: 'children',
        value: 'value',
        label: 'label'
      },
      OrdersFrom: [],
      obj: {
        query: '',
        pagenum: 1,
        pagesize: 10
      },
      total: 0,
      dialogFormVisible: false,
      dialogFormVise: false,
      dialogFmVisible: false,
      DDId: 0,
      // 订单状态数据
      DDfrom: {
        is_send: '',
        order_pay: '',
        order_price: '',
        order_number: '',
        pay_status: ''
      }
    }
  },
  created() {
    this.getOrders()
  },
  mounted() {},
  methods: {
    // 订单状态
    // DD(row) {
    //   this.from.Input = ''
    //   console.log(row)
    //   console.log(this.DDfrom)
    //   this.DDId = row.order_id
    //   this.DDfrom.is_send = row.is_send
    //   this.DDfrom.order_pay = row.order_pay
    //   this.DDfrom.order_price = row.order_price
    //   this.DDfrom.order_number = row.order_number
    //   this.DDfrom.pay_status = row.pay_status
    //   this.dialogFmVisible = true
    // },
    // 修改订单状态接口
    // async getDDzt() {
    //   const res = await this.$QHL.DingDanapi(this.DDId, this.DDfrom)
    //   console.log(res)
    //   this.getOrders()
    //   this.dialogFmVisible = false
    // },
    // 物流弹框
    WL() {
      this.activities = WL.data
      this.dialogFormVise = true
    },
    // 点击出修改地址模态框
    showAddress() {
      this.Options = Addres
      this.dialogFormVisible = true
    },
    handleChange() {},
    // 搜索
    // toSreach: _.debounce(function () {
    //   // console.log(this.obj.query)
    //   this.getOrders()
    // }, 1000),
    //   分页
    handleSizeChange(val) {
      this.obj.pagesize = val
      this.getOrders()
    },
    handleCurrentChange(val) {
      this.obj.pagenum = val
      this.getOrders()
    },
    // 获取表格数据
    async getOrders() {
      const res = await this.$QHL.Ordersapi(this.obj)
      const { goods, total } = res
      this.OrdersFrom = goods
      this.total = total
      console.log(res)
    }
  }
}
</script>
<style scoped lang="scss">
.input-with-select {
  width: 30%;
}
.btn {
  margin-left: 5px;
}
::v-deep.cell {
  font-size: 12px;
}
.in1 {
  width: 80%;
}
.jl {
  width: 80%;
}
</style>
